package com.iotechn.unimall.data.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.iotechn.unimall.data.domain.UserCardDO;
import com.iotechn.unimall.data.dto.UserCardDTO;
import com.iotechn.unimall.data.dto.user.UserAccountDTO;
import com.iotechn.unimall.data.dto.userCard.UserCardSalseStatisticDTO;
import com.iotechn.unimall.data.dto.userCard.UserCardStatisticDTO;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 用户充值卡
 * 
 * @author hct
 * @email 77802226@qq.com
 * @date 2020-03-15 20:45:43
 */
public interface UserCardMapper extends BaseMapper<UserCardDO> {

    /*@Override
    @Transactional(rollbackFor = Exception.class)
    public Integer productCard(Long adminId, Long cardId,Long money) throws ServiceException {

    }*/
    List<UserCardDO> selectUserCardDOsPageStore(
            @Param("cardNo") String cardNo,
            @Param("cardId") Long cardId,
            @Param("money") Integer money,
            @Param("activateStrat") Date activateStrat,
            @Param("activateEnd") Date activateEnd,
            @Param("usageStart") Date usageStart,
            @Param("usageEnd") Date usageEnd,
            @Param("cardStatus") Integer cardStatus,
            @Param("limit") Integer limit,
            @Param("pageNo") Integer pageNo);

    List<UserCardDO> selectUserCardDOsPage(@Param("cardNo") String cardNo,@Param("cardId") Long cardId,@Param("cardStatus") Integer cardStatus,@Param("limit") Integer limit,@Param("pageNo") Integer pageNo);

    Boolean batchInsertList(@Param("userCardDoList") List<UserCardDO> userCardDoList);

    List<UserCardDTO> selectUserCardPage(@Param("nickName") String nickName,@Param("userId") Long userId, @Param("cardNo") String cardNo,@Param("offset") Integer offset, @Param("limit") Integer limit);

    Long countUserCard(@Param("nickName") String nickName,@Param("userId") Long userId, @Param("cardNo") String cardNo);

    List<String> getCardNo();

    /**
     * 统计用查询卡
     * @param gmtStart
     * @param gmtEnd
     * @return
     */
    List<UserAccountDTO> getCardByStatistic(@Param("gmtStart") Date gmtStart,@Param("gmtEnd") Date gmtEnd);

    /**
     * 卡充值统计
     * @param gmtStart
     * @param gmtEnd
     * @return
     */
    List<UserAccountDTO> cardRechargeStatistic(@Param("gmtStart") Date gmtStart, @Param("gmtEnd") Date gmtEnd);

    /**
     * 区间内 卡消费
     * @param gmtStart
     * @param gmtEnd
     * @return
     */
    List<UserAccountDTO> cardConsumeStatistic(@Param("gmtStart") Date gmtStart, @Param("gmtEnd") Date gmtEnd);

    /**
     * 会员卡退费
     * @param gmtStart
     * @param gmtEnd
     * @return
     */
    List<UserAccountDTO>  cardReturnStatistic(@Param("gmtStart") Date gmtStart, @Param("gmtEnd") Date gmtEnd);

    /**
     * 卡余额查询
     * @param gmtTime
     * @return
     */
    List<UserAccountDTO> cardBalanceStatistic(@Param("gmtTime") Date gmtTime);

    /** 批量修改卡 根据卡号 */
    Integer updateBatchByNo(@Param("storeId") Long storeId,@Param("startCard") String startCard,@Param("endCard") String endCard);

    /** 会员卡销售统计 */
    List<UserCardSalseStatisticDTO> cardSalseStatistic(@Param("startTime") Date startTime, @Param("endTime") Date endTime);


    List<UserCardDO> selectUserCardStoreApp(@Param("search") String search,@Param("page") Integer page,@Param("limit") Integer limit);

    List<UserCardStatisticDTO> userCardStatistic(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}
